#!/bin/bash

ENV_CFG=./env.cfg
if [ -f ${ENV_CFG} ] ; then
	chmod 777 ${ENV_CFG}
	source ${ENV_CFG}
fi

function docker_install()
{
  de=`docker --version 2>/dev/null`
  if [ "$?" -eq "0" ];then
     echo "docker 已安装"
  else
     sh scripts/docker_install.sh
  fi    
}

function load_image()
{
  sh scripts/load_image.sh ${images}
}

function init_env()
{
  sed -i "s|{ip}|${ip}|g" docker-compose.yaml
  sed -i "s|{port}|${port}|g" docker-compose.yaml

  sed -i "s|{ip}|${ip}|g" data/storage/storage.conf
  sed -i "s|{port}|${port}|g" data/storage/storage.conf

  mkdir -p ./data/tracker/data
  mkdir -p ./data/storage/storage
  mkdir -p ./data/storage/store_path
  mkdir -p ./data/storage/data
  mkdir -p ./data/storage/store_path
}


docker_install
load_image
init_env

